package com.UI;

import com.Model.StudentDBModel;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

/*This class starts as the first thing when the app is loaded
 * If the user is registered it sends the user to the courses
 * If the not registered then it sends the user to the registration page*/
public class StartPage extends Activity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);

		// check to see if there is a user in the DB
		StudentDBModel account = new StudentDBModel(this);
		int numUsers = account.getNumUsers();

		if (numUsers > 0) {
			// when a registered user is found, go to the Home page
				Intent homePage = new Intent(this, HomePage.class);
				startActivity(homePage);
				StartPage.this.finish();
		} 
		else {
			// when user is not found, ask them to register
			Intent register = new Intent(this, RegisterUser.class);
			startActivity(register);
			StartPage.this.finish();
		}

	}
}